package sh.action;



import sh.model.User;
import sh.service.UserService;

import com.opensymphony.xwork2.ActionSupport;
import sh.service.impl.UserServiceImpl;

public class RegisterAction extends ActionSupport{
	
	
	private User user;
	//应该有类的命名冲突

	@Override
	public String execute() {
		//System.out.println("到action层" + user.getUserName());
		//UserService userService = new UserServiceImpl();
		//保存用户，根据返回值确定是否保存成功
		try {
			UserService userService = new UserServiceImpl();
			if(userService.add(user)){
				return "success";
			}else{
				return "register_fail";
			}
		} catch (Exception e) {

			e.printStackTrace();
			return "register_fail";
		}
		/*System.out.println("executed");
		
		System.out.println(user.getPassword2());*/
		
	}
	public String show() throws Exception{
		return "success";
	}

	public User getUser() {
		return user;
	}

	public String hello(){
		return "register_fail";
	}

	//@Override
	//public String input(){
	//	return "input";
	//}
	public void setUser(User user) {
		this.user = user;
	}



/*	public void setUser(User user) {
		this.user = user;
	}

	public User getUser() {
		return user;
	}*/

	
}
